package com.goodedeeds.webapp.admin.controller;

import com.goodedeeds.webapp.controller.BaseDashboardAction;
import com.goodedeeds.webapp.controller.DashboardTab;
import com.goodedeeds.webapp.controller.IDashboardTab;
import com.youtills.core.email.EmailMessage;
import com.youtills.core.email.EmailSender;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.StreamingResolution;
import net.sourceforge.stripes.action.UrlBinding;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: ravi
 * Date: 8/13/12
 * Time: 8:00 PM
 * To change this template use File | Settings | File Templates.
 */
@UrlBinding(SendMailAction.URL)
public class SendMailAction extends BaseDashboardAction {

   public static final String URL = "/send-mail.action";

    private static final String DASHBOARD_CONTENT = JSP_ROOT + "/admin/send-mail.jsp";

    private String fromAddress;
    private String toAddress;
    private String subject;
    private String body;
    private boolean html;
    private String msg;
    
    
    public SendMailAction() {
    }

    /* (non-Javadoc)
      * @see com.depo.quiggle.view.controller.BaseDashboardAction#getDashboardContent()
      */
    @Override
    public String getDashboardContent() {
        return DASHBOARD_CONTENT;
    }


//    @Override
//    public String getHeaderInclude() {
//        return HEADER_INCLUDE;
//    }

    @Override
    public IDashboardTab getCurrentTab() {
        return DashboardTab.SITE_ADMINISTRATION;
    }

    public String getFromAddress() {
        return fromAddress;
    }

    public void setFromAddress(String fromAddress) {
        this.fromAddress = fromAddress;
    }

    public String getToAddress() {
        return toAddress;
    }

    public void setToAddress(String toAddress) {
        this.toAddress = toAddress;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }

    public boolean getHtml() {
        return isHtml();
    }
    public boolean isHtml() {
        return html;
    }

    public void setHtml(boolean html) {
        this.html = html;
    }

    public Resolution sendMail(){
//        EmailMessage message = new EmailMessage(toAddress);
//        message.setFrom(fromAddress);
//        message.setSubject(subject);
//        message.setBody(body);
//        message.setHtml(html);
//
//        EmailSender.send(message);
//        msg = "Email has been sent to " + toAddress;
        return showPage();
    }    
   
    public String getMsg() {
        return msg;
    }
  
}